home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / ExecTests / runtest.m < prev    next >
Text File  |  1990-08-31  |  2KB  |  66 lines

  1. import OutStream, InStream from "Builtins"
  2. export runtest to "RunTest"
  3.  
  4. const runtest == immutable object runtest
  5.   export create, getSignature
  6.   const runTestType == type runTestType
  7.     operation finish [Boolean]
  8.     operation done
  9.     operation check  [Boolean, String]
  10.   end runTestType
  11.   function getSignature -> [r : Signature]
  12.     r <- runTestType
  13.   end getSignature
  14.   operation create [in : InStream, out : OutStream, testName : String] -> [r : runTestType]
  15.     r <- object aRunTest
  16.       export finish, check, done
  17.       monitor
  18.     var firstCheckMessagePrinted : Boolean <- false
  19.     var success : Boolean <- true
  20.     operation finish [result : Boolean]
  21.       if testname !== nil then
  22.         if firstCheckMessagePrinted then
  23.           out.PutString["Test \""]
  24.           out.PutString[testname]
  25.           out.PutString["\""]
  26.         end if
  27.         if result then
  28.           out.PutString[" completed successfully.\^J"]
  29.         else
  30.           out.PutString[" failed.\^J"]
  31.         end if
  32.       end if
  33.       in.close
  34.       out.close
  35.     end finish
  36.     operation check [b : Boolean, test : String]
  37.       success <- success & b
  38.       if ! b then
  39.         if ! firstCheckMessagePrinted then
  40.           out.PutString["\^J"]
  41.           firstCheckMessagePrinted <- true
  42.         end if
  43.         out.PutString["  Test \""]
  44.         out.PutString[test]
  45.         out.PutString["\" failed.\^J"]
  46.       end if
  47.     end check
  48.     function getSuccess -> [r : Boolean]
  49.       r <- success
  50.     end getSuccess
  51.     initially
  52.       if testname !== nil then
  53.         out.PutString["Test \""]
  54.         out.PutString[testname]
  55.         out.PutString["\" starting ..."]
  56.         out.flush
  57.       end if
  58.     end initially
  59.       end monitor
  60.       operation done 
  61.     finish[getSuccess[]]
  62.       end done
  63.     end aRunTest
  64.   end create
  65. end runtest
  66.